<%@ page contentType="text/html; charset=utf-8" language="java"%>
<%@ page import="net.fckeditor.*"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.List"%>
<%@page import="com.travelsky.airchina.boarding.domain.NewsColumn"%>
<%@ include file="/common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>管理中心 - 修改视频</title>
	<%@ include file="/common/meta.jsp" %>
	<link href="${ctx}/css/system/general.css" rel="stylesheet" type="text/css" />
	<link href="${ctx}/css/system/main.css" rel="stylesheet" type="text/css" />
	<link href="${ctx}/css/system/category.css" rel="stylesheet" type="text/css" />	
	<script type="text/javascript" src="${ctx}/js/checkFrameSet.js"></script>
	<script type="text/javascript" src="${ctx}/js/jquery-1.4.min.js"></script>
	<script type="text/javascript" src="${ctx}/js/json.min.js"></script>
	<script type="text/javascript" src="${ctx}/js/newscategory.js"></script>
	<script type="text/javascript" src="${ctx}/js/flowplayer-3.2.6.min.js"></script>
	<script language="JavaScript">
	 var contextPath = "${ctx}";
	 $(document).ready(findCategoryList);
	</script>
	<%
		FCKeditor fckEditor = new FCKeditor(request, "content");
		fckEditor.setHeight("560");
		String content = (String)request.getAttribute("content");
		fckEditor.setValue(content!=null?content:"");
	%>
</head>
<body>
<h1>
<c:if test="${USER_OPERATION_URIS_MAP['/system/video/manage']!=null}">
<span class="action-span"><a href="${ctx}/system/video/manage">视频列表</a></span>
</c:if>
<span class="action-span1"><a href="#">管理中心</a>  - 修改视频 </span>
<div style="clear:both"></div>
</h1>

<div class="main-div">
  <form:form modelAttribute="news" action="${ctx}/system/video/update" method="post" name="theForm" id="theForm" enctype ="multipart/form-data" onsubmit="this.submit.disabled='true';">
  <input type="hidden" name="p_cate_id" id="p_cate_id" value="${news.newsColumn.id}"/>
  <input type="hidden" name="is_leaf" id="is_leaf" value=""/>
  <input type="hidden" name="originalVideoPath" id="originalVideoPath" value="${news.videoPath}"/>
  <form:hidden path="id"/>
  <table width="100%" id="general-table">
      <tr>
        <td class="label"><form:label for="title" path="title" cssErrorClass="error">视频名称</form:label></td>
        <td>
          <form:input path="title" maxlength="50" size="50" /> <font color="red">*</font> <form:errors path="title" /></td>
      </tr>
      <tr>
        <td class="label"><form:label for="author" path="author" cssErrorClass="error">视频作者</form:label></td>
        <td><form:input path="author" maxlength="20" size="50" /></td>
      </tr>
      <tr>
        <td class="label"><form:label for="source" path="source" cssErrorClass="error">视频来源</form:label></td>
        <td><form:input path="source" maxlength="50" size="50" /></td>
      </tr>
      <tr>
        <td class="label">新闻栏目</td>
        <td>
	       <div class="cascading-container">
		    <ol id="J_OlCascadingList">
		      <li id="l_1" class="root">
		        <ul id="u_1">
		           <c:if test="${rootNewsColumns!=null}">
			           <c:forEach items="${rootNewsColumns}" var="itemTemp">
			             <c:choose>
			                <c:when test="${itemTemp.isLeaf==0}">
					           <c:choose>
					             <c:when test="${rootNewsColumnId==itemTemp.id}">
			           <li id="${itemTemp.id}" class="parent selected"><span>${itemTemp.name}</span><input type="hidden" id="imageTextId${itemTemp.id}" value="${itemTemp.isImageText}"/></li>
					             </c:when>
					             <c:otherwise>
			           <li id="${itemTemp.id}" class="parent"><span>${itemTemp.name}</span><input type="hidden" id="imageTextId${itemTemp.id}" value="${itemTemp.isImageText}"/></li>
					             </c:otherwise>
					           </c:choose>
			                </c:when>
			                <c:otherwise>
					           <c:choose>
					             <c:when test="${rootNewsColumnId==itemTemp.id}">
			           <li id="${itemTemp.id}" class="selected"><span>${itemTemp.name}</span><input type="hidden" id="imageTextId${itemTemp.id}" value="${itemTemp.isImageText}"/></li>
					             </c:when>
					             <c:otherwise>
			           <li id="${itemTemp.id}"><span>${itemTemp.name}</span><input type="hidden" id="imageTextId${itemTemp.id}" value="${itemTemp.isImageText}"/></li>
					             </c:otherwise>
					           </c:choose>
			                </c:otherwise>
			             </c:choose>
			           </c:forEach>
		           </c:if>
		        </ul>
		      </li>
		      
		      <%
		      @SuppressWarnings("unchecked")
		      List<Long> cateIdList = (List<Long>)request.getAttribute("newsColumnIds");
		      Long newsColumnId = (Long)request.getAttribute("newsColumnId");
		      @SuppressWarnings("unchecked")
		      Map<Long,List<NewsColumn>> parentCateListMap = (Map<Long,List<NewsColumn>>)request.getAttribute("map");
		      if(parentCateListMap!=null && parentCateListMap.keySet().size()>0){
		         int liIndex = 0;
		         for(Long pId:parentCateListMap.keySet()){
		            liIndex++;
		       %>
		                <li id="_o_l_<%=liIndex%>">
		                  <ul id="_o_l_u_<%=liIndex%>">
		       <%
		            List<NewsColumn> cateList = parentCateListMap.get(pId);
		            for(NewsColumn cate:cateList){
		                     if("0".equals(cate.getIsLeaf())){
		                        if(cateIdList.contains(cate.getId())){
		                    %>
		                    <li id="<%=cate.getId()%>" class="parent selected"><span><%=cate.getName()%></span><input type="hidden" id="imageTextId<%=cate.getId()%>" value="<%=cate.getIsImageText()%>"/></li>
		                    <%
		                        }else{
		                           if(cate.getId().equals(newsColumnId)){
		                    %>
		                    <li id="<%=cate.getId()%>" class="parent selected"><span><%=cate.getName()%></span><input type="hidden" id="imageTextId<%=cate.getId()%>" value="<%=cate.getIsImageText()%>"/></li>
		                    <%
		                           }else{
		                    %>
		                    <li id="<%=cate.getId()%>" class="parent"><span><%=cate.getName()%></span><input type="hidden" id="imageTextId<%=cate.getId()%>" value="<%=cate.getIsImageText()%>"/></li>
		                    <%
		                           }
		                        }
		                     }else{
		                        if(cateIdList.contains(cate.getId())){
		                    %>
		                    <li id="<%=cate.getId()%>" class="selected"><span><%=cate.getName()%></span><input type="hidden" id="imageTextId<%=cate.getId()%>" value="<%=cate.getIsImageText()%>"/></li>
		                    <%
		                        }else{
		                           if(cate.getId().equals(newsColumnId)){
		                    %>
		                    <li id="<%=cate.getId()%>" class="selected"><span><%=cate.getName()%></span><input type="hidden" id="imageTextId<%=cate.getId()%>" value="<%=cate.getIsImageText()%>"/></li>
		                    <%
		                           }else{
		                    %>
		                    <li id="<%=cate.getId()%>"><span><%=cate.getName()%></span><input type="hidden" id="imageTextId<%=cate.getId()%>" value="<%=cate.getIsImageText()%>"/></li>
		                    <%
		                           }
		                        }
		                     }
		          }
		      %>
		                  </ul>
		                </li>
		      <%
		         }
		      }
		      %>
		    </ol>
		  </div>
        </td>
      </tr>
      <c:choose>
         <c:when test="${news.videoPath!=null}">
      <tr>
        <td class="label">视频</td>
        <td>
        <c:if test="${news.videoPath!=null}">
        <a href="${ctx}${FLV_VIDEO_PATH}${news.videoPath}" style="display:block;width:425px;height:300px;" id="player"></a>
		<script language="JavaScript">
			flowplayer("player", "${ctx}/resources/flowplayer-3.2.7.swf", {
				clip:  {
					autoPlay: true,
					autoBuffering: true
				}
			});
		</script>
        </c:if>
        </td>
      </tr>
      <tr>
        <td class="label">选择视频</td>
        <td>
          <input type="file" id="videoFile" name="videoFile"/>
        </td>
      </tr>
         </c:when>
         <c:otherwise>
      <tr>
        <td class="label">选择视频</td>
        <td>
          <input type="file" id="videoFile" name="videoFile"/>
        </td>
      </tr>
         </c:otherwise>
      </c:choose>

      <tr>
        <td class="label">状态</td>
        <td>
        <form:select path="status">
        <c:choose>
          <c:when test="${video.status==NEWS_STATUS_NO_AUDIT}">
          <form:option value="${NEWS_STATUS_NO_AUDIT}">未审核</form:option>
          <form:option value="${NEWS_STATUS_AUDIT_PUBLISH}">审核发布</form:option>
          <form:option value="${NEWS_STATUS_AUDIT_NOT_PASS}">审核未通过</form:option>
          </c:when>
          <c:when test="${video.status==NEWS_STATUS_AUDIT_PUBLISH}">
          <form:option value="${NEWS_STATUS_AUDIT_PUBLISH}">审核发布</form:option>
          <form:option value="${NEWS_STATUS_NO_AUDIT}">未审核</form:option>
          <form:option value="${NEWS_STATUS_AUDIT_NOT_PASS}">审核未通过</form:option>
          </c:when>
          <c:when test="${video.status==NEWS_STATUS_AUDIT_NOT_PASS}">
          <form:option value="${NEWS_STATUS_AUDIT_NOT_PASS}">审核未通过</form:option>
          <form:option value="${NEWS_STATUS_NO_AUDIT}">未审核</form:option>
          <form:option value="${NEWS_STATUS_AUDIT_PUBLISH}">审核发布</form:option>
          </c:when>
          <c:otherwise>
          <form:option value="${NEWS_STATUS_AUDIT_NOT_PASS}">审核未通过</form:option>
          <form:option value="${NEWS_STATUS_NO_AUDIT}">未审核</form:option>
          <form:option value="${NEWS_STATUS_AUDIT_PUBLISH}">审核发布</form:option>
          </c:otherwise>
        </c:choose>
        </form:select>
        </td>
      </tr>
      
      <tr>
        <td class="label">描述</td>
        <td>
        <%out.println(fckEditor);%>
        </td>
      </tr>
      </table>
      <div class="button-div">
        <input type="submit" value=" 确定 " />
      </div>
  </form:form>
</div>
</body>
</html>